home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_HDF.idb / usr / freeware / include / hdf / hchunks.h.z / hchunks.h
Encoding:
C/C++ Source or Header  |  1999-01-26  |  11.8 KB  |  286 lines

  1. /****************************************************************************
  2.  * NCSA HDF                                                                 *
  3.  * Software Development Group                                               *
  4.  * National Center for Supercomputing Applications                          *
  5.  * University of Illinois at Urbana-Champaign                               *
  6.  * 605 E. Springfield, Champaign IL 61820                                   *
  7.  *                                                                          *
  8.  * For conditions of distribution and use, see the accompanying             *
  9.  * hdf/COPYING file.                                                        *
  10.  *                                                                          *
  11.  ****************************************************************************/
  12.  
  13. /* $Id: hchunks.h,v 1.16 1997/10/24 21:00:35 koziol Exp $ */
  14.  
  15. /*-----------------------------------------------------------------------------
  16.  * File:         hchunks.h
  17.  * Purpose:      Header file for Chunked elements
  18.  * Dependencies: tbbt.c mcache.c
  19.  * Invokes:      none
  20.  * Contents:     Structures & definitions for chunked elements
  21.  * Structure definitions: DIM_DEF, HCHUNK_DEF
  22.  * Constant definitions:
  23.  * Author: -GeorgeV -  9/3/96
  24.  *---------------------------------------------------------------------------*/
  25.  
  26. /* avoid re-inclusion */
  27. #ifndef __HCHUNKS_H
  28. #define __HCHUNKS_H
  29.  
  30. /* required includes */
  31. #include "hfile.h"  /* special info stuff */
  32.  
  33. #ifdef   _HCHUNKS_MAIN_
  34. /* Private to 'hchunks.c' */
  35.  
  36. #include "tbbt.h"   /* TBBT stuff */
  37. #include "mcache.h" /* caching routines */
  38. #include "hcomp.h"  /* For Compression */
  39.  
  40. /* Define class, class version and name(partial) for chunk table i.e. Vdata */
  41. #if 0 /* moved definition of class of vdata to hlimits.h */
  42. #define _HDF_CHK_TBL_CLASS "_HDF_CHK_TBL_" /* 13 bytes */
  43. #define _HDF_CHK_TBL_CLASS_VER  0          /* zero version number for class */
  44. #endif /* moved definition of class of vdata to hlimits.h */ 
  45. #define _HDF_CHK_TBL_NAME  "_HDF_CHK_TBL_" /* 13 bytes */
  46.  
  47. /* Define field name for each chunk record i.e. Vdata record */
  48. #define _HDF_CHK_FIELD_1   "origin"  /* 6 bytes */
  49. #define _HDF_CHK_FIELD_2   "chk_tag" /* 7 bytes */
  50. #define _HDF_CHK_FIELD_3   "chk_ref" /* 7 bytes */
  51. #define _HDF_CHK_FIELD_NAMES   "origin,chk_tag,chk_ref" /* 22 bytes */
  52.  
  53. /* Define version number for chunked header format */
  54. #define _HDF_CHK_HDR_VER   0  /* zero version for format header */
  55.  
  56. #endif /* _HCHUNKS_MAIN_ */
  57.  
  58. /* Public structures */
  59.  
  60. /* Structure for each Data array dimension Defintion */
  61. typedef struct dim_def_struct {
  62.     int32 dim_length;          /* length of this dimension */
  63.     int32 chunk_length;        /* chunk length along this dimension */
  64.     int32 distrib_type;        /* Data distribution along this dimension */
  65. } DIM_DEF, * DIM_DEF_PTR;
  66.  
  67. /* Structure for each Chunk Definition*/
  68. typedef struct hchunk_def_struct {
  69.     int32    chunk_size;     /* size of this chunk*/
  70.     int32    nt_size;        /* number type size i.e. size of data type */
  71.     int32    num_dims;       /* number of actual dimensions */
  72.     DIM_DEF *pdims;          /* ptr to array of dimension records for this chunk*/
  73.     int32   chunk_flag;      /* multiply specialness? SPECIAL_COMP */
  74.  
  75.     /* For Compression info */
  76.     comp_coder_t comp_type;     /* Compression type */
  77.     comp_model_t model_type;    /* Compression model type */
  78.     comp_info  *cinfo;        /* Compression info struct */
  79.     model_info *minfo;        /* Compression model info struct */
  80. }HCHUNK_DEF, * HCHUNK_DEF_PTR;
  81.  
  82. /* Private structues */
  83. #ifdef _HCHUNKS_MAIN_
  84. /* Private to 'hchunks.c' */
  85.  
  86. /* Structure for each Data array dimension */
  87. typedef struct dim_rec_struct {
  88.     /* fields stored in chunked header */
  89.     int32 flag;                /* distrib_type(low 8 bits 0-7)
  90.                                   - Data distribution along this dimension 
  91.                                   other(medium low 8 bits 8-15)
  92.                                   - regular/unlimited dimension? */
  93.     int32 dim_length;          /* length of this dimension */
  94.     int32 chunk_length;        /* chunk length along this dimension */
  95.     
  96.     /* info determined from 'flag' field */
  97.     int32 distrib_type;        /* Data distribution along this dimension */
  98.     int32 unlimited;           /* regular(0) or unlimited dimension(1) */
  99.  
  100.     /* computed fields */
  101.     int32 last_chunk_length;   /* last chunk length along this dimension */
  102.     int32 num_chunks;          /* i.e. "dim_length / chunk_length" */
  103. } DIM_REC, * DIM_REC_PTR;
  104.  
  105. /* Structure for each Chunk */
  106. typedef struct chunk_rec_struct {
  107.     int32 chunk_number;      /* chunk number from coordinates i.e. origin */
  108.     int32 chk_vnum;          /* chunk vdata record number i.e. position in table*/
  109.  
  110.     /* chunk record fields stored in Vdata Table */
  111.     int32  *origin;          /* origin -> position of chunk */
  112.     uint16 chk_tag;          /* DFTAG_CHUNK or another Chunked element? */
  113.     uint16 chk_ref;          /* reference number of this chunk */
  114. }CHUNK_REC, * CHUNK_REC_PTR;
  115.  
  116. /* information on this special chunk data elt */
  117. typedef struct chunkinfo_t
  118. {
  119.     intn        attached;     /* how many access records refer to this elt */
  120.     int32       aid;          /* Access id of chunk table i.e. Vdata */
  121.  
  122.     /* chunked element format header  fields */
  123.     int32       sp_tag_header_len; /* length of the special element header */
  124.     uint8       version;      /* Version of this Chunked element */
  125.     int32       flag;         /* flag for multiply specialness ...*/
  126.     int32       length;       /* the actual length of the data elt */
  127.     int32       chunk_size;   /* the logical size of the chunks */
  128.     int32       nt_size;      /* number type size i.e. size of data type */
  129.     uint16      chktbl_tag;   /* DFTAG_VH - Vdata header */
  130.     uint16      chktbl_ref;   /* ref of the first chunk table structure(VDATA) */
  131.     uint16      sp_tag;       /* For future use.. */
  132.     uint16      sp_ref;       /* For future use.. */
  133.     int32       ndims;        /* number of dimensions of chunk */
  134.     DIM_REC     *ddims;       /* array of dimension records */
  135.     int32       fill_val_len; /* fill value number of bytes */
  136.     VOID        *fill_val;    /* fill value */
  137.     /* For each specialness, only one for now SPECIAL_COMP */
  138.     int32       comp_sp_tag_head_len; /* Compression header length */
  139.     VOID        *comp_sp_tag_header;  /* compression header */
  140.  
  141.     /* For Compression info */
  142.     comp_coder_t comp_type;            /* Compression type */
  143.     comp_model_t model_type;           /* Compression model type */
  144.     comp_info   *cinfo;               /* Compression info struct */
  145.     model_info  *minfo;               /* Compression model info struct */
  146.  
  147.     /* additional memory resident data structures to be used */
  148.     int32       *seek_chunk_indices; /* chunk array indicies relative
  149.                                         to the other chunks */
  150.     int32       *seek_pos_chunk;     /* postion within the current chunk */
  151.     int32       *seek_user_indices;  /* user postion within the element  */
  152.     TBBT_TREE   *chk_tree;    /* TBBT tree of all accessed table entries 
  153.                                  i.e. CHUNK_REC's read/written/modified */
  154.     MCACHE      *chk_cache;   /* chunk cache */
  155.     int32       num_recs;     /* number of Table(Vdata) records */
  156. }
  157. chunkinfo_t;
  158. #endif /* _HCHUNKS_MAIN_ */
  159.  
  160. #if defined c_plusplus || defined __cplusplus
  161. extern      "C"
  162. {
  163. #endif                          /* c_plusplus || __cplusplus */
  164.  
  165. /*
  166. ** from hchunks.c
  167. */
  168.  
  169. /* User Public */
  170.     extern int32 HMCcreate
  171.         (int32 file_id,       /* IN: file to put linked chunk element in */
  172.          uint16 tag,          /* IN: tag of element */
  173.          uint16 ref,          /* IN: ref of element */
  174.          uint8 nlevels,       /* IN: number of levels of chunks */
  175.          int32 fill_val_len,  /* IN: fill value length in bytes */
  176.          VOID  *fill_val,     /* IN: fill value */
  177.          HCHUNK_DEF *chk_array /* IN: structure describing chunk distribution
  178.                                  can be an array? but we only handle 1 level */);
  179.  
  180.     extern int32 HMCsetMaxcache
  181.         (int32 access_id, /* IN: access aid to mess with */
  182.          int32 maxcache,  /* IN: max number of pages to cache */
  183.          int32 flags      /* IN: flags = 0, HMC_PAGEALL */);
  184.  
  185.     extern int32 HMCwriteChunk
  186.         (int32 access_id,  /* IN: access aid to mess with */
  187.          int32 *origin,    /* IN: origin of chunk to write */
  188.          const VOID *datap /* IN: buffer for data */);
  189.  
  190.     extern int32 HMCreadChunk
  191.         (int32 access_id,  /* IN: access aid to mess with */
  192.          int32 *origin,    /* IN: origin of chunk to read */
  193.          VOID *datap       /* IN: buffer for data */);
  194.  
  195.     extern int32 HMCPcloseAID
  196.         (accrec_t *access_rec /* IN:  access record of file to close */);
  197.  
  198. /* Library Private */
  199. #ifdef _HCHUNKS_MAIN_
  200.     /* tbbt.h helper routines */
  201.     intn chkcompare(void * k1,   /* IN: first key */
  202.            void * k2,   /* IN: second key */
  203.            intn cmparg /* IN: not sure? */);
  204.     void chkfreekey(void * key /*IN: chunk key */ );
  205.     void chkdestroynode(void * n /* IN: chunk record */ );
  206.  
  207. /* Private to 'hchunks.c' */
  208.     extern int32 HMCPstread
  209.         (accrec_t *access_rec  /* IN: access record to fill in */);
  210.  
  211.     extern int32 HMCPstwrite
  212.         (accrec_t *access_rec  /* IN: access record to fill in */);
  213.  
  214.     extern int32 HMCPseek
  215.         (accrec_t *access_rec, /* IN: access record to mess with */
  216.          int32 offset,         /* IN: seek offset */
  217.          int   origin          /* IN: where we should calc the offset from */);
  218.  
  219.     extern int32 HMCPchunkread
  220.         (VOID  *cookie,    /* IN: access record to mess with */
  221.          int32 chunk_num,  /* IN: chunk to read */
  222.          VOID  *datap      /* OUT: buffer for data */);
  223.  
  224.     extern int32 HMCPread
  225.         (accrec_t * access_rec, /* IN: access record to mess with */
  226.          int32 length,          /* IN: number of bytes to read */
  227.          void * data             /* OUT: buffer for data */);
  228.  
  229.     extern int32 HMCPchunkwrite
  230.         (VOID  *cookie,    /* IN: access record to mess with */
  231.          int32 chunk_num,  /* IN: chunk number */
  232.          const VOID *datap /* IN: buffer for data */);
  233.  
  234.     extern int32 HMCPwrite
  235.         (accrec_t *access_rec, /* IN: access record to mess with */
  236.          int32 length,         /* IN: number of bytes to write */
  237.          const void * data      /* IN: buffer for data */);
  238.  
  239.     extern intn HMCPendaccess
  240.         (accrec_t *access_rec /* IN:  access record to close */);
  241.  
  242.     extern int32 HMCPinfo
  243.         (accrec_t *access_rec,       /* IN: access record of access elemement */
  244.          sp_info_block_t *info_chunk /* OUT: information about the special element */);
  245.  
  246.     extern int32 HMCPinquire
  247.         (accrec_t * access_rec, /* IN:  access record to return info about */
  248.          int32 *pfile_id,       /* OUT: file ID; */
  249.          uint16 *ptag,          /* OUT: tag of info record; */
  250.          uint16 *pref,          /* OUT: ref of info record; */
  251.          int32 *plength,        /* OUT: length of element; */
  252.          int32 *poffset,        /* OUT: offset of element -- meaningless */
  253.          int32 *pposn,          /* OUT: current position in element; */
  254.          int16 *paccess,        /* OUT: access mode; */
  255.          int16 *pspecial        /* OUT: special code; */);
  256.  
  257. #endif /* _HCHUNKS_MAIN_ */
  258.  
  259. #if defined c_plusplus || defined __cplusplus
  260. }
  261. #endif                          /* c_plusplus || __cplusplus */
  262.  
  263. #ifndef _HCHUNKS_MAIN_
  264. /* not in master file hchunk.c */
  265. extern funclist_t chunked_funcs;  /* functions to perform chunking */
  266.  
  267. #else /* in hchunks.c */
  268.  
  269. /* the accessing special function table for chunks */
  270. funclist_t  chunked_funcs =
  271. {
  272.     HMCPstread,
  273.     HMCPstwrite,
  274.     HMCPseek,
  275.     HMCPinquire,
  276.     HMCPread,
  277.     HMCPwrite,
  278.     HMCPendaccess,
  279.     HMCPinfo,
  280.     NULL         /* no routine registerd */
  281. };
  282.  
  283. #endif
  284.  
  285. #endif /* __HCHUNKS_H */
  286.